package batch.premium.mobillion;

import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import javax.xml.parsers.*;

import java.util.Date;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.dbutils.QueryRunner;

import org.apache.log4j.*;

import java.sql.Connection;
import java.util.List;

import java.util.*;
import java.io.*;

import batch.common.code.CodeManager;
import batch.common.db.*;
import batch.common.report.*;

public class JavaGameXMLParsing extends DefaultHandler
{
    private Connection    conn;
    private QueryRunner   qRunner;
    private String[]      site_cd;
    private String        log_path;
    private String        file_nm;
    private String        strDate;

    private StringBuffer  sbfCharacter = new StringBuffer();
    private StringBuffer  strSql       = new StringBuffer();
    private StringBuffer  strError     = new StringBuffer();

    private int           id_count = 0;  //contents_id seq

    private String[]      contents_value;
    private List          ltData;

    private boolean       processYN = false;

    final String CP_ID         = "0001";
    final String MCATE_ID      = "04";
    final String TODAY         = DateFormatUtils.format(new Date(), "yyyyMMdd");
    final String STRSUBJECT    = "Mobillion Java Game[04] Batch Error(" + TODAY + ")";
    final String CONTENTS_PATH = "/home01/sfc/batch/premium/data/mobillion/javagame/contents/";

    public JavaGameXMLParsing(){
        ;
    }

    public static void main( String[] args ){
        JavaGameXMLParsing xmlP = new JavaGameXMLParsing();
        xmlP.site_cd   = StringUtils.split(args[0], "/");
        xmlP.strDate   = args[1];

        Logger.getLogger("mobillion.javagame").info("( * ) Start mobillion.javagame.");
        xmlP.xmlParsing_start();
        Logger.getLogger("mobillion.javagame").info("( * ) End mobillion.javagame.");
    }

    public void xmlParsing_start(){
        log_path = "/home01/sfc/batch/premium/data/mobillion/javagame/sh/" + strDate + "/";
        file_nm  = "/home01/sfc/batch/premium/data/mobillion/javagame/xml/04_0001_" + strDate + ".xml";

        try{
            ltData = new LinkedList();
            Logger.getLogger("mobillion.javagame").info("( * ) Start parsing.");
            SAXParserFactory  factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware (true);
            SAXParser parser = factory.newSAXParser();
            parser.parse(file_nm, this);
            Logger.getLogger("mobillion.javagame").info("( * ) End parsing.");

            conn = ConnectionManager.getConnection();
            conn.setAutoCommit(false);

            //To delete the previous Data
            Logger.getLogger("mobillion.javagame").info("( * ) Start Data delete.");
            for(int i=0;i<site_cd.length;i++){
                String[] strParams = new String[]{site_cd[i], CP_ID, MCATE_ID};

                deleteData(conn, strParams);
                deletePhone(conn, strParams);
                deletePhoneDisplay(conn, strParams);
            }
            Logger.getLogger("mobillion.javagame").info("( * ) End Data delete.");
            int nInserted = 0;

            //To make Today's Data
            Logger.getLogger("mobillion.javagame").info("( * ) Start Data insert.");
            for(Iterator i = ltData.iterator(); i.hasNext();) {
                String[] temp = (String[])i.next();

                //for(int j=0;j<temp.length;j++) System.out.println("temp[" + j + "]==" + temp[j]);

                existFile(temp);
                addData(conn, temp);
                addPhone(conn, temp);
                shellFileWrite(temp);

                nInserted++;
                //if(nInserted>10) break;
            }
            Logger.getLogger("mobillion.javagame").info("( * ) End Data insert.");
            // select phone list insert
            CodeManager codeMgr = new CodeManager();
            String[] lang_cd = null;
            Logger.getLogger("mobillion.javagame").info("( * ) Start Display Phone data delete & insert.");
            for(int i=0;i<site_cd.length;i++){
                lang_cd = codeMgr.getLangs(site_cd[i]);
            	for(int j = 0; j < lang_cd.length; j++) {
            		addPhoneDisplay(conn, site_cd[i], lang_cd[j]);      
	            }
            }
            Logger.getLogger("mobillion.javagame").info("( * ) End Display Phone data delete & insert.");
            
            conn.commit();
            Logger.getLogger("mobillion.javagame").info("Success. " + nInserted + " inserted. ");
        }
        catch(Exception ex){
            if (conn != null) try { conn.rollback(); } catch (Exception ee) {}

            StackTraceElement[] stElement = ex.getStackTrace();

            strError.setLength(0);
            strError.append("---------------------  " + STRSUBJECT + "  ---------------------\n")
                    .append("file name :        " + file_nm + "                              \n")
                    .append("Description :        " + ex.toString() + "                              \n");

            for(int p=0; p<stElement.length;p++){
                strError.append(stElement[p].toString() + "\n");
            }

            strError.append("--------------------------------------------------------------- \n");

            Logger.getLogger("mobillion.javagame").info(strError.toString());

            //processFail(CONTENTS_PATH);  //Delete Images
            //processFail(log_path);       //Delete Shell Files
            sendErrMail(strError);
        }
        finally{
            if(conn != null) try { conn.close(); } catch(Exception ex) {}
        }
    }

    public void startDocument() throws SAXException{
        ;
    }

    public void endDocument() throws SAXException {
        ;
    }

    /*****************************************************************************/
    /* name : startElement)                                                      */
    /* argument : String uri :                                                   */
    /*            String localName : ��ġ����ڸ� �������� �ʴ� ���ø�           */
    /*            String qName : ��ġ����ڸ� ����� ��ĸ�                      */
    /*            Attributes atts : ��d�� �Ӽ� �Ǵ� ����Ʈ�� �Ӽ�               */
    /* return :                                                                  */
    /* description :                                                             */
    /* process :  String[] contents_value : data                                 */
    /*            contents_value[0]  : site_cd                                   */
    /*            contents_value[1]  : lang_cd                                   */
    /*            contents_value[2]  : cp_id                                     */
    /*            contents_value[3]  : mcate_cd                                  */
    /*            contents_value[4]  : scate_cd                                  */
    /*            contents_value[5]  : cpcontents_id                             */
    /*            contents_value[6]  : contents_id                               */
    /*            contents_value[7]  : title_nm                                  */
    /*            contents_value[8]  : shortcut1_nm                              */
    /*            contents_value[9]  : shortcut2_nm                              */
    /*            contents_value[10] : shortcut3_nm                              */
    /*            contents_value[11] : shortcut4_nm                              */
    /*            contents_value[12] : mainimages_nm                             */
    /*            contents_value[13] : manualimage_nm                            */
    /*            contents_value[14] : process_cd                                */
    /*            contents_value[15] : order_url                                 */
    /*            contents_value[16] : introduction                              */
    /*            contents_value[17] : webmanual                                 */
    /*            contents_value[18] : point_num                                 */
    /*            contents_value[19] : point_yn                                  */
    /*            contents_value[20] : availablephone                            */
    /*            contents_value[21] : ordercode                                 */
    /*            contents_value[22] : ivr_price                                 */
    /* etc :                                                                     */
    /*****************************************************************************/
    public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{
        sbfCharacter.setLength(0);

        if(qName.equals("contents")){
            String xml_site_cd = atts.getValue("site_cd");

            for(int i=0; i<site_cd.length ; i++){
                if((xml_site_cd.substring(0,3)).compareToIgnoreCase(site_cd[i]) == 0){
                    processYN = true;
                    contents_value = new String[23];

                    contents_value[0] = xml_site_cd.substring(0,3).toUpperCase();

                    if(contents_value[0].compareToIgnoreCase("BEL") == 0){
                        contents_value[1] = xml_site_cd.substring(4).toUpperCase();
                    }
                    else{
                        if(contents_value[0].equals("GBR")){
                            contents_value[1] = "ENG";
                        }
                        else{
                            contents_value[1] = contents_value[0];
                        }
                    }

                    contents_value[2]  = atts.getValue("cp_id");
                    contents_value[3]  = atts.getValue("mcate_cd");
                    contents_value[4]  = atts.getValue("scate_cd");
                    contents_value[5]  = atts.getValue("contents_id").trim();
//                    contents_value[6]  = DateFormatUtils.format(new Date(), "MMddHHmmss") + getCount();
                    contents_value[6]  = atts.getValue("contents_id").trim();
                    contents_value[7]  = atts.getValue("title_nm");
                    contents_value[8]  = atts.getValue("shortcut1_nm");
                    contents_value[9]  = atts.getValue("shortcut2_nm");
                    contents_value[10] = atts.getValue("shortcut3_nm");
                    contents_value[11] = atts.getValue("shortcut4_nm");
                    contents_value[12] = atts.getValue("mainimage_nm");
                    contents_value[14] = atts.getValue("process_cd");
                    contents_value[15] = atts.getValue("order_url");
                    contents_value[21] = atts.getValue("ordercode");
                }
            }
        }
        else if(qName.equals("point_num")){
            System.out.println("contents_id==" + contents_value[5]);
            contents_value[19] = StringUtils.defaultString(atts.getValue("point_yn"));
        }
    }

    public void endElement(String uri, String localName, String qName) throws SAXException{
        if(processYN){
            if(qName.equals("availablephone")){
                contents_value[20]= StringUtils.defaultString(contents_value[20]) + sbfCharacter.insert(0, "SGH-").append("/").toString();
            }
            else if(qName.equals("introduction")){
                contents_value[16] = sbfCharacter.toString();
            }
            else if(qName.equals("webmanual")){
                ;
            }
            else if(qName.equals("newline")){
                contents_value[17] = StringUtils.defaultString(contents_value[17]) + sbfCharacter.append("<br/>").toString();
            }
            else if(qName.equals("point_num")){
                contents_value[18] = StringUtils.defaultString(sbfCharacter.toString(), "0");
            }
            else if(qName.equals("ivr_price")){
                contents_value[22] = StringUtils.defaultString(sbfCharacter.toString(), "0");
            }
            else if(qName.equals("contents") && processYN){
                for(int i=0;i<contents_value.length;i++){
                    contents_value[i] = StringUtils.defaultString(contents_value[i]);
                }

                if(contents_value[14].equals("I")){
                    ltData.add(contents_value);
                }

                processYN = false;
            }

            sbfCharacter.setLength(0);
        }
    }

    /*****************************************************************************/
    /* name : characters()                                                       */
    /* argument : char[] ch : ĳ����                                             */
    /*            int start : ĳ���� �迭���� ���� 'ġ                          */
    /*            int len : ĳ���� �迭�κ��� ���Ǵ� ĳ���ͼ�                  */
    /* return :                                                                  */
    /* description :                                                             */
    /* etc :                                                                     */
    /*****************************************************************************/
    public void characters( char[] ch, int start, int len ){
        //System.out.println("characters == [" + new String(ch, start, len) + "]");
        sbfCharacter.append(ch, start, len);
    }

    public void ignorableWhitespace(char ch[], int start, int length) throws SAXException{
        ;
    }

    public void addData(Connection conn, String[] add_contents_value) throws Exception{
        int iRE = 0;
        strSql.setLength(0);

        try{
            qRunner = new QueryRunner();

            strSql.append("INSERT INTO G_" + add_contents_value[0] + "_PL_CPGAME \n")
                  .append("          ( CONTENTS_ID                               \n")
                  .append("          , MCATE_CD                                  \n")
                  .append("          , SCATE_CD                                  \n")
                  .append("          , LANG_CD                                   \n")
                  .append("          , CP_ID                                     \n")
                  .append("          , CPCONTENTS_ID                             \n")
                  .append("          , TITLE_NM                                  \n")
                  .append("          , SHORTCUT1_NM                              \n")
                  .append("          , SHORTCUT2_NM                              \n")
                  .append("          , SHORTCUT3_NM                              \n")
                  .append("          , SHORTCUT4_NM                              \n")
                  .append("          , MAINIMAGE_NM                              \n")
                  .append("          , POINT_NUM                                 \n")
                  .append("          , POINT_YN                                  \n")
                  .append("          , ORDER_URL                                 \n")
                  .append("          , WEBMANUAL                                 \n")
                  .append("          , INTRODUCTION                              \n")
                  .append("          , VISIBLE_CD                                \n")
                  .append("          , ORDER_CD                                  \n")
                  .append("          , IVR_PRICE)                                \n")
                  .append("   VALUES ( ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?                                         \n")
                  .append("          , ?)                                        \n");


            ArrayList params = new ArrayList();

            params.add(add_contents_value[6] );  //CONTENTS_ID
            params.add(add_contents_value[3] );  //MCATE_CD
            params.add(add_contents_value[4] );  //SCATE_CD
            params.add(add_contents_value[1] );  //LANG_CD
            params.add(add_contents_value[2] );  //CP_ID
            params.add(add_contents_value[5] );  //CPCONTENTS_ID
            params.add(add_contents_value[7] );  //TITLE_NM
            params.add(add_contents_value[8] );  //SHORTCUT1_NM
            params.add(add_contents_value[9] );  //SHORTCUT2_NM
            params.add(add_contents_value[10]);  //SHORTCUT3_NM
            params.add(add_contents_value[11]);  //SHORTCUT4_NM
            params.add(add_contents_value[12]);  //MAINIMAGE_NM
            params.add(add_contents_value[18]);  //POINT_NUM
            params.add(add_contents_value[19]);  //POINT_YN
            params.add(add_contents_value[15]);  //ORDER_URL
            params.add(add_contents_value[17]);  //WEBMANUAL
            params.add(add_contents_value[16]);  //INTRODUCTION
            params.add("A"                   );  //VISIBLE_CD
            params.add(add_contents_value[21]);  //ORDER CODE
            params.add(add_contents_value[22]);  //IVR_PRICE

            iRE = qRunner.update(conn, strSql.toString(), params.toArray());

            if(iRE != 1){
                throw new Exception("CP Insert Error");
            }
        }
        finally{
            ;
        }
    }

    public void addPhone(Connection conn, String[] add_contents_value) throws Exception{
        int iRE = 0;
        String[] availablephone = StringUtils.split(add_contents_value[20], "/");
        int size = (availablephone == null) ? 0 : availablephone.length;
        strSql.setLength(0);

        try{
            qRunner = new QueryRunner();

            strSql.append("INSERT INTO G_" + add_contents_value[0] + "_PL_CPPHONE \n")
                  .append("          ( CP_ID                                      \n")
                  .append("          , MCATE_CD                                   \n")
                  .append("          , LANG_CD                                    \n")
                  .append("          , SCATE_CD                                   \n")
                  .append("          , CONTENTS_ID                                \n")
                  .append("          , PHONE)                                     \n")
                  .append("   VALUES ( ?                                          \n")
                  .append("          , ?                                          \n")
                  .append("          , ?                                          \n")
                  .append("          , ?                                          \n")
                  .append("          , ?                                          \n")
                  .append("          , ?)                                         \n");

            for(int i=0;i<size;i++){
                ArrayList params = new ArrayList();

                params.add(add_contents_value[2]);       //CP_ID
                params.add(add_contents_value[3]);       //MCATE_CD
                params.add(add_contents_value[1]);       //LANG_CD
                params.add(add_contents_value[4]);       //SCATE_CD
                params.add(add_contents_value[6]);       //CONTENTS_ID
                params.add(availablephone[i]);           //PHONE

                iRE = qRunner.update(conn, strSql.toString(), params.toArray());

                if(iRE != 1){
                    throw new Exception("Phone Insert Error");
                }
            }
        }
        finally{
            ;
        }
    }
    
    public void addPhoneDisplay(Connection conn, String strSite_cd, String strLang_cd) throws Exception{
        int iRE = 0;
        strSql.setLength(0);

        try{
            qRunner = new QueryRunner();

            strSql.append("	INSERT INTO G_" + strSite_cd + "_PL_CPPHONEDISPLAY		\n");
            strSql.append("		(CP_ID, MCATE_CD, LANG_CD, PHONE )              	\n");
            strSql.append("	    (                                               	\n");
            strSql.append("		SELECT                                          	\n");
            strSql.append("	    	'"+CP_ID+"' CP_ID, '"+MCATE_ID+"' MCATE_CD  	\n");
            strSql.append("			, '"+strLang_cd+"' LANG_CD, PHONE           	\n");
            strSql.append("		FROM                                            	\n");
            strSql.append("			(                                           	\n");
            strSql.append("			SELECT                                      	\n");
            strSql.append("				DISTINCT PHONE                          	\n");
            strSql.append("			FROM G_" + strSite_cd + "_PL_CPPHONE            \n");
            strSql.append("			WHERE CP_ID = '"+CP_ID+"'                   	\n");
            strSql.append("				AND MCATE_CD = '"+MCATE_ID+"'           	\n");
            strSql.append("				AND LANG_CD = '"+strLang_cd+"'          	\n");
            strSql.append("			)                                           	\n");
            strSql.append("		)                                               	\n");

            iRE = qRunner.update(conn, strSql.toString(), null);
        }
        finally{
            ;
        }
    }
    
    public void deleteData(Connection conn, String[] strParams) throws Exception{
        strSql.setLength(0);

        try{
            qRunner = new QueryRunner();

            strSql.append("DELETE FROM G_" + strParams[0] + "_PL_CPGAME \n")
                  .append(" WHERE CP_ID    = '" + strParams[1] + "'     \n")
                  .append("   AND MCATE_CD = '" + strParams[2] + "'     \n");

            qRunner.update(conn, strSql.toString());
            Logger.getLogger("mobillion.javagame").info( strParams[0] + " deleteData");
        }
        finally{
            //System.out.println("=====================================================1");
        }
    }

    public void deletePhone(Connection conn, String[] strParams) throws Exception{
        strSql.setLength(0);

        try{
            qRunner = new QueryRunner();

            strSql.append("DELETE FROM G_" + strParams[0] + "_PL_CPPHONE \n")
                  .append(" WHERE CP_ID    = '" + strParams[1] + "'      \n")
                  .append("   AND MCATE_CD = '" + strParams[2] + "'      \n");

            qRunner.update(conn, strSql.toString());
            Logger.getLogger("mobillion.javagame").info( strParams[0] + " deletePhone");

        }
        finally{
            //System.out.println("=====================================================2");
        }
    }
    
    public void deletePhoneDisplay(Connection conn, String[] strParams) throws Exception{
        strSql.setLength(0);
        try{
            qRunner = new QueryRunner();
            
            strSql.append("DELETE FROM G_" + strParams[0] + "_PL_CPPHONEDISPLAY \n")
                  .append(" WHERE CP_ID    = '" + strParams[1] + "'      	\n")
                  .append("   AND MCATE_CD = '" + strParams[2] + "'      	\n");

            qRunner.update(conn, strSql.toString());
            Logger.getLogger("mobillion.javagame").info( strParams[0] + " deletePhoneDisplay");
        }
        
        finally{
            //System.out.println("=====================================================2");
        }
    }
    
    /*****************************************************************************/
    /* name : existFile()                                                        */
    /* argument :                                                                */
    /* return :                                                                  */
    /* description :                                                             */
    /* etc :                                                                     */
    /*****************************************************************************/
    public void existFile(String[] add_contents_value) throws Exception{
        if(!new File(CONTENTS_PATH + add_contents_value[8]).exists()){
            strError.setLength(0);
            strError.append("-----------------  File not found  -------------------\n")
                    .append("contents_id  :     " + add_contents_value[5] + "      \n")
                    .append("mcate_cd     :     " + add_contents_value[3] + "      \n")
                    .append("title_nm     :     " + add_contents_value[7] + "      \n")
                    .append("shortcut1_nm :     " + add_contents_value[8] + "      \n")
                    .append("------------------------------------------------------\n");
            throw new Exception(strError.toString());
        }
        if(!new File(CONTENTS_PATH + add_contents_value[9]).exists()){
            strError.setLength(0);
            strError.append("-----------------  File not found  -------------------\n")
                    .append("contents_id  :     " + add_contents_value[5] + "      \n")
                    .append("mcate_cd     :     " + add_contents_value[3] + "      \n")
                    .append("title_nm     :     " + add_contents_value[7] + "      \n")
                    .append("shortcut2_nm :     " + add_contents_value[9] + "      \n")
                    .append("------------------------------------------------------\n");
            throw new Exception(strError.toString());
        }
        if(!new File(CONTENTS_PATH + add_contents_value[10]).exists()){
            strError.setLength(0);
            strError.append("-----------------  File not found  -------------------\n")
                    .append("contents_id  :     " + add_contents_value[5]  + "     \n")
                    .append("mcate_cd     :     " + add_contents_value[3]  + "     \n")
                    .append("title_nm     :     " + add_contents_value[7]  + "     \n")
                    .append("shortcut3_nm :     " + add_contents_value[10] + "     \n")
                    .append("------------------------------------------------------\n");
            throw new Exception(strError.toString());
        }
        if(!new File(CONTENTS_PATH + add_contents_value[11]).exists()){
            strError.setLength(0);
            strError.append("-----------------  File not found  -------------------\n")
                    .append("contents_id  :     " + add_contents_value[5]  + "     \n")
                    .append("mcate_cd     :     " + add_contents_value[3]  + "     \n")
                    .append("title_nm     :     " + add_contents_value[7]  + "     \n")
                    .append("shortcut4_nm :     " + add_contents_value[11] + "     \n")
                    .append("------------------------------------------------------\n");
            throw new Exception(strError.toString());
        }
        if(!new File(CONTENTS_PATH + add_contents_value[12]).exists()){
            strError.setLength(0);
            strError.append("-----------------  File not found  -------------------\n")
                    .append("contents_id   :    " + add_contents_value[5]  + "     \n")
                    .append("mcate_cd      :    " + add_contents_value[3]  + "     \n")
                    .append("title_nm      :    " + add_contents_value[7]  + "     \n")
                    .append("mainimages_nm :    " + add_contents_value[12] + "     \n")
                    .append("------------------------------------------------------\n");
            throw new Exception(strError.toString());
        }
    }

    public void shellFileWrite(String[] add_contents_value) throws Exception{
        String nas_path = "";
        FileWriter fw = null;

        try{
            String lwSite_cd = add_contents_value[0].toLowerCase();

            nas_path = "/home02/nas/" + lwSite_cd + "_pub/adm/cp/" + CP_ID + "/" + add_contents_value[3] + "/";

            fw = new FileWriter(log_path + add_contents_value[0] + "_" + strDate + ".sh", true);

            fw.write("cp \"" + add_contents_value[8]  + "\" \"" + nas_path + add_contents_value[8]  + "\" \n");
            fw.write("cp \"" + add_contents_value[9]  + "\" \"" + nas_path + add_contents_value[9]  + "\" \n");
            fw.write("cp \"" + add_contents_value[10] + "\" \"" + nas_path + add_contents_value[10] + "\" \n");
            fw.write("cp \"" + add_contents_value[11] + "\" \"" + nas_path + add_contents_value[11] + "\" \n");
            fw.write("cp \"" + add_contents_value[12] + "\" \"" + nas_path + add_contents_value[12] + "\" \n");
        }
        finally{
            if( fw != null ) try { fw.close(); } catch(Exception ex) {}
        }
    }

    public void processFail(String filePath){
        try{
            File[] delFiles = new File(filePath).listFiles();
            for (int i = 0; i < delFiles.length; i++) {
                if (!delFiles[i].isDirectory() && delFiles[i].exists())
                    delFiles[i].delete();
            }
        }
        catch(Exception ex){
            System.out.println("processFail ==" + ex.toString());
        }
    }

    public void sendErrMail(StringBuffer strMsg){
        ReportError.byEmail(STRSUBJECT, strMsg.toString());
    }

    public String getCount(){
        id_count++;

        if(id_count == 10000000){
            id_count = 0;
        }

        String strIdCount = String.valueOf(id_count);

        switch(strIdCount.length()){
            case 1 : strIdCount = "000000" + id_count; break;
            case 2 : strIdCount = "00000"  + id_count; break;
            case 3 : strIdCount = "0000"   + id_count; break;
            case 4 : strIdCount = "000"    + id_count; break;
            case 5 : strIdCount = "00"     + id_count; break;
            case 6 : strIdCount = "0"      + id_count; break;
        }

        return strIdCount;
    }
}
